/**
 * @file     TitereHelper.cpp
 * @brief    This is the implementation of TitereHelper interface.
 *
 * @author   Franco Riberi
 * @email    fgriberi AT gmail.com
 *
 * Contents: Header file for titere providing PredicateRule interface.
 *
 * System:   titere: Target Ideal TEmperature Rna Expression
 * Language: C++
 *
 * @date February 5, 2015
 *
 * Copyright (C) 2015 Franco Riberi, FuDePAN
 *
 * This file is part of the titere.
 *
 * Titere is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Titere is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with titere. If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "titere/TitereHelper.h"
#include "titere/Exceptions.h"

namespace NSTitere
{
namespace NSHelperFuntion
{

bool checkNucleotide(const biopp::NucSequence& sequence, const Position pos, const Nucleotide nuc)
{
    mili::assert_throw<InvalidPosition>(pos < sequence.length());
    const std::string sequenceToString = sequence.getString();
    return (sequenceToString[pos] == nuc);
}

NucleotidsAmount countNucleotide(const Position from, const Position to, const biopp::NucSequence& sequence, const Nucleotide nuc)
{
    mili::assert_throw<InvalidPosition>(to < sequence.length());
    NucleotidsAmount nucleotideCount = 0u;
    const std::string sequenceToString = sequence.getString();
    for (Position i(from); i <= to; ++i)
    {
        if (sequenceToString[i] == nuc)
        {
            ++nucleotideCount;
        }
    }
    return nucleotideCount;
}

} //NSTitere
} //NSHelperFuntion